cmake_minimum_required(VERSION 3.14)
project(NetworkLogger LANGUAGES CXX)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ../lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../bin)

# 将Logger构建为库
add_library(net_logger_lib
    TimeStamp.cc
    TimeStamp.h
    Logger.cc
    Logger.h
    noncopyable.h
)

# 包含目录
target_include_directories(net_logger_lib PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
)

# 设置 spdlog 为头文件库
add_library(spdlog INTERFACE)
target_include_directories(spdlog INTERFACE 
    ${CMAKE_CURRENT_SOURCE_DIR}/spdlog
)

# 链接库
target_link_libraries(net_logger_lib PUBLIC
    spdlog
)

# 添加测试子目录
add_subdirectory(test)

# 安装规则 - 将库文件安装到系统lib目录
install(TARGETS net_logger_lib
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
)